<?php
/**
 * ============================================================================
 * 版权所有 2008-2011 多多网络，并保留所有权利。
 * 网站地址: http://soft.duoduo123.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
session_start();
error_reporting(0);
include_once 'comm/config.php';
include 'comm/class_db.php';
include_once 'comm/checkpostandget.php';
include_once 'comm/page.class.php';
$shai_set=include 'data/shai.php';
include 'data/expression.php';
$shaicat_arr=$shai_set['shai_cat'];

$id=(int)$_GET['id'];
if($id==0){
    header('Location:baobeilist.php');
}
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=6;
$page2=($page-1)*$pagesize;

$sql="update ".$BIAOTOU."shai set hits=hits+1 where id='".$id."' limit 1";
mysql_query($sql);

$sql="select a.`ddusername`,a.`image`,a.`hart`,a.`comment`,a.`catid`,a.`dduserid`,a.keywords,a.xs,a.time,a.price,a.title,a.fxje,a.tao_id,a.click_url,b.hart as hart_num from ".$BIAOTOU."shai as a,".$BIAOTOU."user as b where a.dduserid=b.Id and a.id='$id' limit 1";
$query=mysql_query($sql);
if($query==''){
    header('Location:baobeilist.php');
}
if($query==''){echo mysql_error();}
$info=mysql_fetch_array($query);
foreach($expression as $k=>$v){
    $info['comment'] = str_replace('{' .$v. '}','<img src="images/emoticons/' . $k . '.gif"/>',$info['comment']); 
}

/*if($info['fxje']>0 && $info['click_url']!=''){
    $gotoitem="gotoitem.php?url=".base64_encode($info['click_url'].'&u='.$_SESSION['dduserid']);
}*/


$keywords_arr = preg_split('/[\n\r\t\s]+/i', $info['keywords']);

$sql="select id from ".$BIAOTOU."shai where xs='shai' and dduserid='".$info['dduserid']."'"; //晒单宝贝数量
$query=mysql_query($sql);
$shai_nums=mysql_num_rows($query);
$shai_nums=$shai_nums?$shai_nums:0;

$sql="select id from ".$BIAOTOU."shai where xs='share' and dduserid='".$info['dduserid']."'"; //分享宝贝数量
$query=mysql_query($sql);
$share_nums=mysql_num_rows($query);
$share_nums=$share_nums?$share_nums:0;

$sql="select id from ".$BIAOTOU."shai_comment where shai_id='".$id."'"; //评论数量
$query=mysql_query($sql);
$comment_nums=mysql_num_rows($query);

$sql="select comment,ddusername,dduserid,time from ".$BIAOTOU."shai_comment as a where shai_id='".$id."' order by id desc limit $page2,$pagesize"; //评论
$query=mysql_query($sql);
$i=0;
while($row=mysql_fetch_array($query)){
    $comment_arr[$i]=$row;
	foreach($expression as $k=>$v){
        $comment_arr[$i]['comment'] = str_replace('{' .$v. '}','<img src="images/emoticons/' . $k . '.gif"/>',$comment_arr[$i]['comment']); 
    }
	$i++;
}

$sql="select id,image,title from ".$BIAOTOU."shai where catid='".$info['catid']."' order by hart desc limit 0,4";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
    $orther_baobei[]=$row;
}

$tag='shai';
$pagetag='baobei';
include_once 'comm/wjt.php';
include_once 'comm/seo.php';

if($info['fxje']>0){
	$gotoitem="view".$url_head_iid.$info['tao_id'].$url_end;
}
else{
    $gotoitem="http://item.taobao.com/item.htm?id=".$info['tao_id'];
}

//引入模版文件
include 'template/'.MOBAN.'/baobei.tpl.php';
mysql_close();
?>